#!/usr/bin/env python3

print("\n##########################8.1#########################")
def greet_user(name):
	"""
	显示简单的问候语
	比如：呵呵
	"""
	print('%s Hello!' % name.title())

greet_user('zs')

print("\n##########################prac-8.1#########################")


print("\n##########################8.2#########################")
def describe_pet(animal_type,pet_name = 'unnamed dog'):
	print('I have a %s' % animal_type)
	print('My %s`s name is %s' % (animal_type,pet_name.title()))

describe_pet('dog','haluo')
describe_pet('cat','tom')
describe_pet(pet_name='nidaye',animal_type='cat')
describe_pet('cat')

print("\n##########################prac-8.2#########################")
def make_shirt(size = 'L',text = 'I love Python'):
	print('your shirt,size : %s ,text : %s' % (size,text))

make_shirt(10,'hahahaah')
make_shirt(text='are u ok??',size=222)
print('')
make_shirt()
make_shirt('M')
make_shirt('XLL','I do not love u')

def describe_city(city_name,country = 'China'):
	print('%s is in %s' % (city_name.title(),country))

print()
describe_city('guangzhou')
describe_city('shanghai')
describe_city('new york','USA')

print("\n##########################8.3#########################")
print("\n##########################prac-8.3#########################")
def make_album(singer_name,album_name,song_num = 10):
	album = {}
	album['singer_name'] = singer_name.title()
	album['album_name'] = album_name.title()
	album['song_num'] = song_num
	return album;

album = make_album('mickle jackson','beat it')
print(album)
album = make_album('zhang xue you','wen bie')
print(album)
album = make_album('liu dehua','wang qing shui',100)
print(album)

albums = []
while False: ## change it to True if want to run it
	singer_name = input('what is the singer`s name:')
	album_name = input('what is the album name:')
	song_num = input('how many songs in the album:')
	albums.append(make_album(singer_name,album_name,song_num))
	repeat = input('*************continue(y/n)**************:')
	if repeat == 'n':
		break;

print(albums)

print("\n##########################prac-8.4#########################")
magicians = ['zs','ls','ww','zl','tq']
def show_magicians(magicians):
	for magician in magicians:
		print(magician)

def make_great(magicians):
	i = 0
	while i < len(magicians):
		magicians[i] = ('the great ' + magicians[i]).title()
		i+=1

magicians1 = magicians[:]
make_great(magicians1)
show_magicians(magicians1)
show_magicians(magicians)


print("\n##########################8.5#########################")
def make_pizza(size,*toppings):
	print('Make a %sinch pizza with the following toppings:' % size)
	for item in toppings:
		print('-' + item)

make_pizza(8,'baba')
make_pizza(16,'baba','water','lajiaofen')

def test_param(a,b,c,d='ddd',*e,**f):
	r = {}
	r['a'] = a
	r['b'] = b
	r['c'] = c
	r['d'] = d
	i = 1
	for item in e:
		r['e' + str(i)] = item
		i+=1

	for k,v in f.items():
		r[k] = v

	return r

r = test_param('a','b','c','d','e1','e2','e3',f1='f1',f2='f2')

print(r)

print("\n##########################prac-8.5#########################")
def make_car(manufacturer,model,**prop):
	car = {}
	car['manufacturer'] = manufacturer
	car['model'] = model
	if prop:
		for k,v in prop.items():
			car[k] = v
	return car

car = make_car('me','X001')
print(car)
car = make_car('you','X002',color='yellow',length=999)
print(car)


print("\n##########################8.6#########################")
